﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;


namespace Managistics.Model.Mappings
{
    public class GoodMap : ClassMap<Good>
    {

        public GoodMap()
        {
            Schema(Constants._tblSchema);
            Table(Constants._tblItem);
            LazyLoad();

            Id(x => x.Code).GeneratedBy.Assigned().Column("ITEM_ID");
            //References(x => x.ItemType).Column("ITEM_TYPE_ID").Fetch.Join();
            References(x => x.ItemType).Column("ITEM_TYPE_ID");
            References(x => x.UnitItem).Column("UNIT_ITEM_ID");

            Map(x => x.ProductCode).Column("PRODUCT_CODE").Length(20);
            Map(x => x.ProductName).Column("PRODUCT_NAME").Length(50);
            Map(x => x.OrderCode).Column("ORDER_CODE").Length(20);
            Map(x => x.Supplierid).Column("SUPPLIERID").Not.Nullable().Length(20);
            Map(x => x.Name).Column("ITEM_NAME_1").Not.Nullable().Length(300);
            Map(x => x.ItemName2).Column("ITEM_NAME_2").Length(300);
            Map(x => x.WarrantyPeriod).Column("WARRANTY_PERIOD").Length(50);
            Map(x => x.DescriptionItem).Column("DESCRIPTION_ITEM").Length(200);
            Map(x => x.WeightItem).Column("WEIGHT_ITEM").Length(20);
            Map(x => x.SizeItem).Column("SIZE_ITEM").Length(20);
            Map(x => x.VatItem).Column("VAT_ITEM").Precision(5);
            Map(x => x.NoteItem).Column("NOTE_ITEM").Length(200);
            Map(x => x.SellPriceNotIncludeVat).Column("SELL_PRICE_NOT_INCLUDE_VAT").Precision(53);
            Map(x => x.QuantityInCarton).Column("QUANTITY_IN_CARTON").Precision(10);
            Map(x => x.MinQtyOfStock).Column("MIN_QTY_OF_STOCK").Precision(53);
            Map(x => x.Colour).Column("COLOUR").Length(20);
            Map(x => x.InStock).Column("IN_STOCK").Not.Nullable().Precision(53);
            Map(x => x.BuyPriceNotIncludeVat).Column("BUY_PRICE_NOT_INCLUDE_VAT").Not.Nullable().Precision(53);
            Map(x => x.Convertunit).Column("ConvertUnit").Precision(10);
            Map(x => x.Paritycode).Column("ParityCode").Length(6);
        }
    }
}
